#############################################################################
##
#W  refine.gd                DifSets Package                     Dylan Peifer
##
##  Functions find all possible difference set/sum preimages of difference
##  sums.
##

# FEATURE
DeclareGlobalFunction( "IsCoPrime" );  # 判断两个元素是否互素
# FEATURE
DeclareGlobalFunction( "AllCoPrime" );  # 给出小于v的数中与v互素的所有数
# FEATURE Multipliers
DeclareGlobalFunction( "Multipliers" );  # 返回当前群的所有可能乘子
DeclareGlobalFunction( "MultiplierTheorem" );  # 利用乘子定理找出乘子，而不返回乘子猜想（可能为空，即不存在乘子）
DeclareGlobalFunction( "FindAllMultipliersOfDifferenceSet" );  # 返回给定群的所有满足乘子定理的乘子（适用于差集）
DeclareGlobalFunction( "FindAllMultipliersOfDifferenceSetPair" );  # 返回给定群的所有满足乘子定理的乘子（适用于差集偶）
DeclareGlobalFunction( "Export" );

# FEATURE
DeclareGlobalFunction( "TracksOfGroup" );  # 将群划分成多个轨道
# FEATURE
DeclareGlobalFunction( "TracksOfCoset" );  # 将陪集划分成多个轨道

#############################################################################
##
#F  AllRefinedDifferenceSets( <G>, <N>, <difsums> )
##
##  <#GAPDoc Label="AllRefinedDifferenceSets">
##  <ManSection>
##  <Func Name="AllRefinedDifferenceSets" Arg="G, N, difsums"/>
##
##  <Description>
##  Returns a list of all difference sets that are preimages of difference
##  sums contained in the list <A>difsums</A> of difference sums in group
##  <A>G</A> mod its normal subgroup <A>N</A>. Difference sums in
##  <A>difsums</A> are all assumed to be the same size.
##
##  <Example><![CDATA[
##  gap> G := SmallGroup(16, 5);;
##  gap> N := Subgroup(G, [G.2, G.4]);;
##  gap> AllRefinedDifferenceSets(G, N, [[3,1,1,1], [2,2,2,0]]);
##  [ [ 1, 3, 2, 8, 4, 15 ], [ 1, 3, 2, 8, 9, 11 ], [ 1, 3, 2, 13, 4, 11 ],
##    [ 1, 3, 2, 13, 9, 15 ], [ 1, 3, 6, 8, 4, 11 ], [ 1, 3, 6, 8, 9, 15 ],
##    [ 1, 3, 6, 13, 4, 15 ], [ 1, 3, 6, 13, 9, 11 ], [ 1, 5, 2, 6, 4, 15 ],
##    [ 1, 5, 2, 6, 9, 11 ], [ 1, 5, 2, 13, 4, 9 ], [ 1, 5, 2, 13, 11, 15 ],
##    [ 1, 5, 6, 8, 4, 9 ], [ 1, 5, 6, 8, 11, 15 ], [ 1, 5, 8, 13, 4, 15 ],
##    [ 1, 5, 8, 13, 9, 11 ], [ 1, 10, 2, 6, 4, 11 ], [ 1, 10, 2, 6, 9, 15 ],
##    [ 1, 10, 2, 8, 4, 9 ], [ 1, 10, 2, 8, 11, 15 ], [ 1, 10, 6, 13, 4, 9 ],
##    [ 1, 10, 6, 13, 11, 15 ], [ 1, 10, 8, 13, 4, 11 ], [ 1, 10, 8, 13, 9, 15 ],
##    [ 3, 5, 2, 6, 4, 11 ], [ 3, 5, 2, 6, 9, 15 ], [ 3, 5, 2, 8, 4, 9 ],
##    [ 3, 5, 2, 8, 11, 15 ], [ 3, 5, 6, 13, 4, 9 ], [ 3, 5, 6, 13, 11, 15 ],
##    [ 3, 5, 8, 13, 4, 11 ], [ 3, 5, 8, 13, 9, 15 ], [ 3, 10, 2, 6, 4, 15 ],
##    [ 3, 10, 2, 6, 9, 11 ], [ 3, 10, 2, 13, 4, 9 ], [ 3, 10, 2, 13, 11, 15 ],
##    [ 3, 10, 6, 8, 4, 9 ], [ 3, 10, 6, 8, 11, 15 ], [ 3, 10, 8, 13, 4, 15 ],
##    [ 3, 10, 8, 13, 9, 11 ], [ 5, 10, 2, 8, 4, 15 ], [ 5, 10, 2, 8, 9, 11 ],
##    [ 5, 10, 2, 13, 4, 11 ], [ 5, 10, 2, 13, 9, 15 ], [ 5, 10, 6, 8, 4, 11 ],
##    [ 5, 10, 6, 8, 9, 15 ], [ 5, 10, 6, 13, 4, 15 ], [ 5, 10, 6, 13, 9, 11 ] ]
##  ]]></Example>
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
DeclareGlobalFunction( "AllRefinedDifferenceSets" );

#############################################################################
##
#F  NrAllRefinedSets( <G>, <N>, <difsums> )
##
##  <#GAPDoc Label="NrAllRefinedSets">
##  <ManSection>
##  <Func Name="NrAllRefinedSets" Arg="G, N, difsums"/>
##
##  <Description>
##  Returns the number of preimages that will need to be checked during a
##  call to <Ref Func="AllRefinedDifferenceSets"/> with the same arguments.
##  This can give a rough estimate of how long the call will take to
##  complete.
##
##  <Example><![CDATA[
##  gap> G := SmallGroup(16, 5);;
##  gap> N := Subgroup(G, [G.2, G.4]);;
##  gap> NrAllRefinedSets(G, N, [[3,1,1,1], [2,2,2,0]]);
##  472
##  ]]></Example>
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
DeclareGlobalFunction( "NrAllRefinedSets" );

#############################################################################
##
#F  SomeRefinedDifferenceSets( <G>, <N>, <difsums> )
##
##  <#GAPDoc Label="SomeRefinedDifferenceSets">
##  <ManSection>
##  <Func Name="SomeRefinedDifferenceSets" Arg="G, N, difsums"/>
##
##  <Description>
##  Returns a list of some difference sets that are preimages of difference
##  sums contained in the list <A>difsums</A> of difference sums in group
##  <A>G</A> mod its normal subgroup <A>N</A>. At least one member of each
##  equivalence class that would appear in the set of all preimages will be
##  returned, but all preimage difference sets may not appear. Difference
##  sums in <A>difsums</A> are all assumed to be the same size. Current
##  implementation forces the choice of an identity element when possible.
##
##  <Example><![CDATA[
##  gap> G := SmallGroup(16, 5);;
##  gap> N := Subgroup(G, [G.2, G.4]);;
##  gap> SomeRefinedDifferenceSets(G, N, [[3,1,1,1], [2,2,2,0]]);
##  [ [ 1, 3, 2, 8, 4, 15 ], [ 1, 3, 2, 8, 9, 11 ], [ 1, 3, 2, 13, 4, 11 ],
##    [ 1, 3, 2, 13, 9, 15 ], [ 1, 3, 6, 8, 4, 11 ], [ 1, 3, 6, 8, 9, 15 ],
##    [ 1, 3, 6, 13, 4, 15 ], [ 1, 3, 6, 13, 9, 11 ], [ 1, 5, 2, 6, 4, 15 ],
##    [ 1, 5, 2, 6, 9, 11 ], [ 1, 5, 2, 13, 4, 9 ], [ 1, 5, 2, 13, 11, 15 ],
##    [ 1, 5, 6, 8, 4, 9 ], [ 1, 5, 6, 8, 11, 15 ], [ 1, 5, 8, 13, 4, 15 ],
##    [ 1, 5, 8, 13, 9, 11 ], [ 1, 10, 2, 6, 4, 11 ], [ 1, 10, 2, 6, 9, 15 ],
##    [ 1, 10, 2, 8, 4, 9 ], [ 1, 10, 2, 8, 11, 15 ], [ 1, 10, 6, 13, 4, 9 ],
##    [ 1, 10, 6, 13, 11, 15 ], [ 1, 10, 8, 13, 4, 11 ], [ 1, 10, 8, 13, 9, 15 ] ]
##  ]]></Example>
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
DeclareGlobalFunction( "SomeRefinedDifferenceSets" );
# FEATURE
DeclareGlobalFunction( "SubsetSum" );
# FEATURE
DeclareGlobalFunction( "SomeRefinedDifferenceSetsWithMultiplier" );
DeclareGlobalFunction( "SomeRefinedDifferenceSetsUseMultiplier" );

#############################################################################
##
#F  NrSomeRefinedSets( <G>, <N>, <difsums> )
##
##  <#GAPDoc Label="NrSomeRefinedSets">
##  <ManSection>
##  <Func Name="NrSomeRefinedSets" Arg="G, N, difsums"/>
##
##  <Description>
##  Returns the number of preimages that will need to be checked during a
##  call to <Ref Func="SomeRefinedDifferenceSets"/> with the same arguments.
##  This can give a rough estimate of how long the call will take to
##  complete.
##
##  <Example><![CDATA[
##  gap> G := SmallGroup(16, 5);;
##  gap> N := Subgroup(G, [G.2, G.4]);;
##  gap> NrSomeRefinedSets(G, N, [[3,1,1,1], [2,2,2,0]]);
##  300
##  ]]></Example>
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
DeclareGlobalFunction( "NrSomeRefinedSets" );

#############################################################################
##
#F  SomeRefinedDifferenceSetPairs( <G>, <N>, <difsums>, <e>, <lambda> )
##
##  <#GAPDoc Label="SomeRefinedDifferenceSetPairs">
##  <ManSection>
##  <Func Name="SomeRefinedDifferenceSetPairs" Arg="G, N, difsums, e, lambda"/>
##
##  <Description>
##  Returns a list of some difference set pairs that are preimages of difference
##  sums contained in the list <A>difsums</A> of difference sums in group
##  <A>G</A> mod its normal subgroup <A>N</A>. At least one member of each
##  equivalence class that would appear in the set of all preimages will be
##  returned, but all preimage difference set pairs may not appear. Difference
##  sums in <A>difsums</A> are all assumed to be the same size. Current
##  implementation forces the choice of an identity element when possible.
##
##  <Example><![CDATA[
##  gap> G := SmallGroup(16, 5);;
##  gap> N := Subgroup(G, [G.2, G.4]);;
##  gap> SomeRefinedDifferenceSetPairs(G,N,[[[3,1,1,1],[3,1,1,1]], [[2,2,2,0],[2,2,2,0]]],6,2);
##  [ [ [ 1, 3, 2, 8, 4, 15 ], [ 1, 3, 2, 8, 4, 15 ] ], [ [ 1, 3, 2, 8, 9, 11 ], [ 1, 3, 2, 8, 9, 11 ] ],
##  [ [ 1, 3, 2, 13, 4, 11 ], [ 1, 3, 2, 13, 4, 11 ] ], [ [ 1, 3, 2, 13, 9, 15 ], [ 1, 3, 2, 13, 9, 15 ] ],
##  [ [ 1, 3, 6, 8, 4, 11 ], [ 1, 3, 6, 8, 4, 11 ] ], [ [ 1, 3, 6, 8, 9, 15 ], [ 1, 3, 6, 8, 9, 15 ] ],
##  [ [ 1, 3, 6, 13, 4, 15 ], [ 1, 3, 6, 13, 4, 15 ] ], [ [ 1, 3, 6, 13, 9, 11 ], [ 1, 3, 6, 13, 9, 11 ] ],
##  [ [ 1, 5, 2, 6, 4, 15 ], [ 1, 5, 2, 6, 4, 15 ] ], [ [ 1, 5, 2, 6, 9, 11 ], [ 1, 5, 2, 6, 9, 11 ] ],
##  [ [ 1, 5, 2, 13, 4, 9 ], [ 1, 5, 2, 13, 4, 9 ] ], [ [ 1, 5, 2, 13, 11, 15 ], [ 1, 5, 2, 13, 11, 15 ] ],
##  [ [ 1, 5, 6, 8, 4, 9 ], [ 1, 5, 6, 8, 4, 9 ] ], [ [ 1, 5, 6, 8, 11, 15 ], [ 1, 5, 6, 8, 11, 15 ] ],
##  [ [ 1, 5, 8, 13, 4, 15 ], [ 1, 5, 8, 13, 4, 15 ] ], [ [ 1, 5, 8, 13, 9, 11 ], [ 1, 5, 8, 13, 9, 11 ] ],
##  [ [ 1, 10, 2, 6, 4, 11 ], [ 1, 10, 2, 6, 4, 11 ] ], [ [ 1, 10, 2, 6, 9, 15 ], [ 1, 10, 2, 6, 9, 15 ] ],
##  [ [ 1, 10, 2, 8, 4, 9 ], [ 1, 10, 2, 8, 4, 9 ] ], [ [ 1, 10, 2, 8, 11, 15 ], [ 1, 10, 2, 8, 11, 15 ] ],
##  [ [ 1, 10, 6, 13, 4, 9 ], [ 1, 10, 6, 13, 4, 9 ] ], [ [ 1, 10, 6, 13, 11, 15 ], [ 1, 10, 6, 13, 11, 15 ] ],
##  [ [ 1, 10, 8, 13, 4, 11 ], [ 1, 10, 8, 13, 4, 11 ] ], [ [ 1, 10, 8, 13, 9, 15 ], [ 1, 10, 8, 13, 9, 15 ] ] ]
##  ]]></Example>
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
# FEATURE SomeRefinedDifferenceSetPairs(G, N, difsums, e, lambda)
DeclareGlobalFunction( "SomeRefinedDifferenceSetPairs" );
# FEATURE
DeclareGlobalFunction( "SomeRefinedDifferenceSetPairsWithMultiplier" );

#############################################################################
##
#F  SomeRefinedDivisibleDifferenceSets(<G>, <N>, <difsums>, <w>, <v>, <l>, <lambda1>, <lambda2>)
##
##  <#GAPDoc Label="SomeRefinedDivisibleDifferenceSets">
##  <ManSection>
##  <Func Name="SomeRefinedDivisibleDifferenceSets" Arg="G, N, difsums, w, v, l, lambda1, lambda2"/>
##
##  <Description>
##  Returns a list of some divisible difference sets that are preimages of difference
##  sums contained in the list <A>difsums</A> of difference sums in group
##  <A>G</A> mod its normal subgroup <A>N</A>. At least one member of each
##  equivalence class that would appear in the set of all preimages will be
##  returned, but all preimage divisible difference sets may not appear. Difference
##  sums in <A>difsums</A> are all assumed to be the same size. Current
##  implementation forces the choice of an identity element when possible.
##
##  <Example><![CDATA[
##  gap> G := SmallGroup(16, 5);;
##  gap> N := Subgroup(G, [G.2, G.4]);;
##  gap> SomeRefinedDivisibleDifferenceSets(G,N,[[3,1,1,1], [2,2,2,0]],16,1,6,0,2);
##  [ [ 1, 3, 5, 2, 4, 12 ], [ 1, 3, 5, 2, 9, 7 ], [ 1, 3, 5, 2, 9, 14 ], [ 1, 3, 5, 2, 15, 7 ], [ 1, 3, 5, 2, 15, 14 ],
##  [ 1, 3, 5, 6, 4, 12 ], [ 1, 3, 5, 6, 15, 12 ], [ 1, 3, 5, 8, 4, 16 ], [ 1, 3, 5, 8, 9, 14 ], [ 1, 3, 5, 8, 11, 12 ],
##  [ 1, 3, 5, 8, 15, 14 ], [ 1, 3, 5, 13, 4, 14 ], [ 1, 3, 5, 13, 9, 16 ], [ 1, 3, 5, 13, 11, 7 ], [ 1, 3, 5, 13, 11, 14 ],
##  [ 1, 3, 5, 13, 11, 16 ], [ 1, 3, 5, 13, 15, 7 ], [ 1, 3, 5, 13, 15, 12 ], [ 1, 3, 10, 2, 9, 7 ], [ 1, 3, 10, 2, 11, 7 ],
##  [ 1, 3, 10, 6, 4, 12 ], [ 1, 3, 10, 6, 4, 16 ], [ 1, 3, 10, 6, 9, 7 ], [ 1, 3, 10, 6, 11, 12 ], [ 1, 3, 10, 6, 11, 16 ],
##  [ 1, 3, 10, 8, 4, 14 ], [ 1, 3, 10, 8, 9, 16 ], [ 1, 3, 10, 8, 11, 7 ], [ 1, 3, 10, 8, 11, 12 ], [ 1, 3, 10, 8, 15, 12 ],
##  [ 1, 3, 10, 8, 15, 14 ], [ 1, 3, 10, 8, 15, 16 ], [ 1, 3, 10, 13, 4, 16 ], [ 1, 3, 10, 13, 9, 14 ], [ 1, 3, 10, 13, 11, 16 ],
##  [ 1, 3, 10, 13, 15, 7 ], [ 1, 5, 10, 2, 4, 16 ], [ 1, 5, 10, 2, 9, 7 ], [ 1, 5, 10, 2, 11, 12 ], [ 1, 5, 10, 2, 15, 7 ],
##  [ 1, 5, 10, 6, 4, 7 ], [ 1, 5, 10, 6, 4, 12 ], [ 1, 5, 10, 6, 4, 14 ], [ 1, 5, 10, 6, 9, 14 ], [ 1, 5, 10, 6, 9, 16 ],
##  [ 1, 5, 10, 6, 11, 7 ], [ 1, 5, 10, 6, 15, 12 ], [ 1, 5, 10, 8, 9, 7 ], [ 1, 5, 10, 8, 9, 14 ], [ 1, 5, 10, 8, 11, 16 ],
##  [ 1, 5, 10, 8, 15, 7 ], [ 1, 5, 10, 8, 15, 14 ], [ 1, 5, 10, 13, 9, 16 ], [ 1, 5, 10, 13, 11, 16 ], [ 1, 3, 2, 8, 4, 9 ],
##  [ 1, 3, 2, 8, 4, 15 ], [ 1, 3, 2, 8, 9, 11 ], [ 1, 3, 2, 8, 11, 15 ], [ 1, 3, 2, 13, 4, 9 ], [ 1, 3, 2, 13, 4, 11 ],
##  [ 1, 3, 2, 13, 9, 15 ], [ 1, 3, 6, 8, 4, 11 ], [ 1, 3, 6, 8, 9, 15 ], [ 1, 3, 6, 8, 11, 15 ], [ 1, 3, 6, 13, 4, 15 ],
##  [ 1, 3, 6, 13, 9, 11 ], [ 1, 3, 8, 13, 4, 9 ], [ 1, 5, 2, 6, 4, 15 ], [ 1, 5, 2, 6, 9, 11 ], [ 1, 5, 2, 8, 9, 15 ],
##  [ 1, 5, 2, 13, 4, 9 ], [ 1, 5, 2, 13, 11, 15 ], [ 1, 5, 6, 8, 4, 9 ], [ 1, 5, 6, 8, 11, 15 ], [ 1, 5, 8, 13, 4, 15 ],
##  [ 1, 5, 8, 13, 9, 11 ], [ 1, 10, 2, 6, 4, 11 ], [ 1, 10, 2, 6, 4, 15 ], [ 1, 10, 2, 6, 9, 15 ], [ 1, 10, 2, 8, 4, 9 ],
##  [ 1, 10, 2, 8, 4, 15 ], [ 1, 10, 2, 8, 11, 15 ], [ 1, 10, 6, 13, 4, 9 ], [ 1, 10, 6, 13, 4, 15 ], [ 1, 10, 6, 13, 11, 15 ],
##  [ 1, 10, 8, 13, 4, 11 ], [ 1, 10, 8, 13, 4, 15 ], [ 1, 10, 8, 13, 9, 15 ] ]
##  ]]></Example>
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
# FEATURE SomeRefinedDivisibleDifferenceSets(G, N, difsums, w, v, l, lambda1, lambda2)
DeclareGlobalFunction( "SomeRefinedDivisibleDifferenceSets" );

#############################################################################
##
#F  SomeRefinedDivisibleDifferenceSetPairs( <G>, <N>, <difsums>, <w>, <v>, <l1>, <l2>, <le>, <lambda1>, <lambda2> )
##
##  <#GAPDoc Label="SomeRefinedDivisibleDifferenceSetPairs">
##  <ManSection>
##  <Func Name="SomeRefinedDivisibleDifferenceSetPairs" Arg="G, N, difsums, w, v, l1, l2, le, lambda1, lambda2"/>
##
##  <Description>
##  Returns a list of some divisible difference set pairs that are preimages of difference
##  sums contained in the list <A>difsums</A> of difference sums in group
##  <A>G</A> mod its normal subgroup <A>N</A>. At least one member of each
##  equivalence class that would appear in the set of all preimages will be
##  returned, but all preimage divisible difference set pairs may not appear. Difference
##  sums in <A>difsums</A> are all assumed to be the same size. Current
##  implementation forces the choice of an identity element when possible.
##
##  <Example><![CDATA[
##  gap> G := SmallGroup(16, 5);;
##  gap> N := Subgroup(G, [G.2, G.4]);;
##  gap> SomeRefinedDivisibleDifferenceSetPairs(G, N, [[[3,1,1,1],[3,1,1,1]], [[2,2,2,0],[2,2,2,0]]],16,1,6,6,6,0,2);
##  [ [ [ 1, 3, 5, 2, 4, 7 ], [ 1, 3, 5, 2, 9, 12 ] ], [ [ 1, 3, 5, 2, 4, 7 ], [ 1, 3, 5, 2, 9, 16 ] ],
##  [ [ 1, 3, 5, 2, 4, 7 ], [ 1, 3, 5, 2, 15, 14 ] ], [ [ 1, 3, 5, 2, 4, 7 ], [ 1, 3, 5, 2, 15, 16 ] ],
##  [ [ 1, 3, 5, 2, 4, 7 ], [ 1, 3, 5, 6, 9, 7 ] ], [ [ 1, 3, 5, 2, 4, 7 ], [ 1, 3, 5, 6, 9, 12 ] ],
##  [ [ 1, 3, 5, 2, 4, 7 ], [ 1, 3, 5, 6, 9, 16 ] ], [ [ 1, 3, 5, 2, 4, 12 ], [ 1, 3, 5, 2, 4, 12 ] ],
##  [ [ 1, 3, 5, 2, 4, 12 ], [ 1, 3, 5, 2, 11, 7 ] ], [ [ 1, 3, 5, 2, 4, 12 ], [ 1, 3, 5, 2, 11, 12 ] ],
##  [ [ 1, 3, 5, 2, 4, 12 ], [ 1, 3, 5, 2, 11, 14 ] ], [ [ 1, 3, 5, 2, 4, 12 ], [ 1, 3, 5, 2, 11, 16 ] ],
##  [ [ 1, 3, 5, 2, 4, 12 ], [ 1, 3, 5, 6, 4, 12 ] ], [ [ 1, 3, 5, 2, 4, 12 ], [ 1, 3, 5, 6, 4, 14 ] ],
##  [ [ 1, 3, 5, 2, 4, 12 ], [ 1, 3, 5, 6, 15, 12 ] ], [ [ 1, 3, 5, 2, 4, 12 ], [ 1, 3, 5, 6, 15, 14 ] ],
##  [ [ 1, 3, 5, 2, 4, 14 ], [ 1, 3, 5, 2, 9, 16 ] ], [ [ 1, 3, 5, 2, 4, 14 ], [ 1, 3, 5, 2, 11, 7 ] ],
##  [ [ 1, 3, 5, 2, 4, 14 ], [ 1, 3, 5, 2, 11, 16 ] ], [ [ 1, 3, 5, 2, 4, 14 ], [ 1, 3, 5, 2, 15, 7 ] ],
##  [ [ 1, 3, 5, 2, 4, 14 ], [ 1, 3, 5, 2, 15, 12 ] ], [ [ 1, 3, 5, 2, 4, 14 ], [ 1, 3, 5, 2, 15, 16 ] ],
##  ....
##  ....]
##  ]]></Example>
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
# FEATURE SomeRefinedDivisibleDifferenceSetPairs(G, N, difsums, w, v, l1, l2, le, lambda1, lambda2)
DeclareGlobalFunction( "SomeRefinedDivisibleDifferenceSetPairs" );

#############################################################################
##
#F  IsDifferenceSetByTable( <table>, <D>, <v>, <lambda> )
##
##  <#GAPDoc Label="IsDifferenceSetByTable">
##  <ManSection>
##  <Func Name="IsDifferenceSetByTable" Arg="table, D, v, lambda"/>
##  </ManSection>
##  <#/GAPDoc>
DeclareGlobalFunction( "IsDifferenceSetByTable" );

#############################################################################
##
#F  IsDifferenceSetPairByTable( <table>, <D1>, <D2>, <v>, <e>, <lambda> )
##
##  <#GAPDoc Label="IsDifferenceSetPairByTable">
##  <ManSection>
##  <Func Name="IsDifferenceSetPairByTable" Arg="table, D1, D2, v, e, lambda"/>
##  </ManSection>
##  <#/GAPDoc>
# FEATURE IsDifferenceSetPairByTable(table, D1, D2, v, e, lambda)
DeclareGlobalFunction( "IsDifferenceSetPairByTable" );

#############################################################################
##
#F  IsDivisibleDifferenceSetByTable(<table>, <D>, <w>, <v>, <l>, <lambda1>, <lambda2>)
##
##  <#GAPDoc Label="IsDivisibleDifferenceSetByTable">
##  <ManSection>
##  <Func Name="IsDivisibleDifferenceSetByTable" Arg="table, D, w, v, l, lambda1, lambda2"/>
##  </ManSection>
##  <#/GAPDoc>
# FEATURE IsDivisibleDifferenceSetByTable(table, D, w, v, l, lambda1, lambda2)
DeclareGlobalFunction( "IsDivisibleDifferenceSetByTable" );

#############################################################################
##
#F  IsDivisibleDifferenceSetPairByTable(<table>, <D1>, <D2>, <w>, <v>, <l1>, <l2>, <le>, <lambda1>, <lambda2>)
##
##  <#GAPDoc Label="IsDivisibleDifferenceSetPairByTable">
##  <ManSection>
##  <Func Name="IsDivisibleDifferenceSetPairByTable" Arg="table, D1, D2, w, v, l1, l2, le, lambda1, lambda2"/>
##  </ManSection>
##  <#/GAPDoc>
# FEATURE IsDivisibleDifferenceSetPairByTable(table, D1, D2, w, v, l1, l2, le, lambda1, lambda2)
DeclareGlobalFunction( "IsDivisibleDifferenceSetPairByTable" );

#############################################################################
##
#F  AllRefinedDifferenceSums( <G>, <N1>, <N2>, <difsums> )
##
##  <#GAPDoc Label="AllRefinedDifferenceSums">
##  <ManSection>
##  <Func Name="AllRefinedDifferenceSums" Arg="G, N1, N2, difsums"/>
##
##  <Description>
##  Returns a list of all difference sums in group <A>G</A> mod its normal
##  subgroup <A>N2</A> that are preimages of difference sums contained in the
##  list <A>difsums</A> of difference sums in group <A>G</A> mod its normal
##  subgroup <A>N1</A>. The subgroup <A>N2</A> must be contained in <A>N1</A>.
##  Difference sums in <A>difsums</A> are all assumed to be the same size.
##
##  <Example><![CDATA[
##  gap> G := SmallGroup(16, 5);;
##  gap> N1 := Subgroup(G, [G.2, G.4]);;
##  gap> N2 := Subgroup(G, [G.2]);;
##  gap> AllRefinedDifferenceSums(G, N1, N2, [[3,1,1,1], [2,2,2,0]]);
##  [ [ 1, 1, 0, 1, 0, 1, 2, 0 ], [ 1, 1, 2, 1, 0, 1, 0, 0 ],
##    [ 1, 0, 1, 1, 0, 2, 1, 0 ], [ 1, 2, 1, 1, 0, 0, 1, 0 ],
##    [ 0, 1, 1, 2, 0, 1, 1, 0 ], [ 2, 1, 1, 0, 0, 1, 1, 0 ] ]
##  ]]></Example>
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
DeclareGlobalFunction( "AllRefinedDifferenceSums" );

#############################################################################
##
#F  NrAllRefinedSums( <G>, <N1>, <N2>, <difsums> )
##
##  <#GAPDoc Label="NrAllRefinedSums">
##  <ManSection>
##  <Func Name="NrAllRefinedSums" Arg="G, N1, N2, difsums"/>
##
##  <Description>
##  Returns the number of preimages that will need to be checked during a
##  call to <Ref Func="AllRefinedDifferenceSums"/> with the same arguments.
##  This can give a rough estimate of how long the call will take to
##  complete.
##
##  <Example><![CDATA[
##  gap> G := SmallGroup(16, 5);;
##  gap> N1 := Subgroup(G, [G.2, G.4]);;
##  gap> N2 := Subgroup(G, [G.2]);;
##  gap> NrAllRefinedSums(G, N1, N2, [[3,1,1,1], [2,2,2,0]]);
##  22
##  ]]></Example>
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
DeclareGlobalFunction( "NrAllRefinedSums" );

#############################################################################
##
#F  SomeRefinedDifferenceSums( <G>, <N1>, <N2>, <difsums> )
##
##  <#GAPDoc Label="SomeRefinedDifferenceSums">
##  <ManSection>
##  <Func Name="SomeRefinedDifferenceSums" Arg="G, N1, N2, difsums"/>
##
##  <Description>
##  Returns a list of some difference sums in group <A>G</A> mod its normal
##  subgroup <A>N2</A> that are preimages of difference sums contained in
##  the list <A>difsums</A> of difference sums in group <A>G</A> mod its
##  normal subgroup <A>N1</A>. At least one member of each equivalence class
##  that would appear in the set of all preimages will be returned, but all
##  preimage difference sums may not appear. The subgroup <A>N2</A> must be
##  contained in <A>N1</A> and difference sums in <A>difsums</A> are all
##  assumed to be the same size. Current implementation forces a choice
##  of nonzero identity coefficient when possible.
##
##  <Example><![CDATA[
##  gap> G := SmallGroup(16, 5);;
##  gap> N1 := Subgroup(G, [G.2, G.4]);;
##  gap> N2 := Subgroup(G, [G.2]);;
##  gap> SomeRefinedDifferenceSums(G, N1, N2, [[3,1,1,1], [2,2,2,0]]);
##  [ [ 1, 1, 0, 1, 0, 1, 2, 0 ], [ 1, 1, 2, 1, 0, 1, 0, 0 ],
##    [ 1, 0, 1, 1, 0, 2, 1, 0 ], [ 1, 2, 1, 1, 0, 0, 1, 0 ],
##    [ 2, 1, 1, 0, 0, 1, 1, 0 ] ]
##  ]]></Example>
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
DeclareGlobalFunction( "SomeRefinedDifferenceSums" );
DeclareGlobalFunction( "SomeRefinedDifferenceSumsOptimized" );
DeclareGlobalFunction( "TracksToTracksTable" );
DeclareGlobalFunction( "SomeRefinedDifferenceSumsUseMultiplier" );

#############################################################################
##
#F  NrSomeRefinedSums( <G>, <N1>, <N2>, <difsums> )
##
##  <#GAPDoc Label="NrSomeRefinedSums">
##  <ManSection>
##  <Func Name="NrSomeRefinedSums" Arg="G, N1, N2, difsums"/>
##
##  <Description>
##  Returns the number of preimages that will need to be checked during a
##  call to <Ref Func="SomeRefinedDifferenceSums"/> with the same arguments.
##  This can give a rough estimate of how long the call will take to
##  complete.
##
##  <Example><![CDATA[
##  gap> G := SmallGroup(16, 5);;
##  gap> N1 := Subgroup(G, [G.2, G.4]);;
##  gap> N2 := Subgroup(G, [G.2]);;
##  gap> NrSomeRefinedSums(G, N1, N2, [[3,1,1,1], [2,2,2,0]]);
##  21
##  ]]></Example>
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
DeclareGlobalFunction( "NrSomeRefinedSums" );

#############################################################################
##
#F  SomeRefinedDifferenceSumsOfDifferenceSetPair(<G>, <N1>, <N2>, <difsums>, <k1>, <k2>, <e>, <lambda>)
##
##  <#GAPDoc Label="SomeRefinedDifferenceSumsOfDifferenceSetPair">
##  <ManSection>
##  <Func Name="SomeRefinedDifferenceSumsOfDifferenceSetPair" Arg="G, N1, N2, difsums, k1, k2, e, lambda"/>
##
##  <Description>
##  Returns a list of some difference sums in group <A>G</A> mod its normal
##  subgroup <A>N2</A> that are preimages of difference sums contained in
##  the list <A>difsums</A> of difference sums in group <A>G</A> mod its
##  normal subgroup <A>N1</A>. At least one member of each equivalence class
##  that would appear in the set of all preimages will be returned, but all
##  preimage difference sums may not appear. The subgroup <A>N2</A> must be
##  contained in <A>N1</A> and difference sums in <A>difsums</A> are all
##  assumed to be the same size. Current implementation forces a choice
##  of nonzero identity coefficient when possible.
##
##  <Example><![CDATA[
##  gap> G := SmallGroup(16, 5);;
##  gap> N1 := Subgroup(G, [G.2, G.4]);;
##  gap> N2 := Subgroup(G, [G.2]);;
##  gap> SomeRefinedDifferenceSumsOfDifferenceSetPair(G, N1, N2, [[[3,1,1,1],[3,1,1,1]], [[2,2,2,0],[2,2,2,0]]],6,6,6,2);
##  [ [ [ 1, 1, 0, 1, 0, 1, 2, 0 ], [ 1, 1, 0, 1, 0, 1, 2, 0 ] ], [ [ 1, 1, 2, 1, 0, 1, 0, 0 ], [ 1, 1, 2, 1, 0, 1, 0, 0 ] ],
##  [ [ 1, 0, 1, 1, 0, 2, 1, 0 ], [ 1, 0, 1, 1, 0, 2, 1, 0 ] ], [ [ 1, 2, 1, 1, 0, 0, 1, 0 ], [ 1, 2, 1, 1, 0, 0, 1, 0 ] ],
##  [ [ 2, 1, 1, 0, 0, 1, 1, 0 ], [ 2, 1, 1, 0, 0, 1, 1, 0 ] ] ]
##  ]]></Example>
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
# FEATURE SomeRefinedDifferenceSumsOfDifferenceSetPair(G, N1, N2, difsums, k1, k2, e, lambda)
DeclareGlobalFunction( "SomeRefinedDifferenceSumsOfDifferenceSetPair" );
DeclareGlobalFunction( "SomeRefinedDifferenceSumsOfDifferenceSetPairOptimized" );

#############################################################################
##
#F  SomeRefinedDifferenceSumsOfDivisibleDifferenceSet(<G>, <N1>, <N2>, <difsums>, <w>, <v>, <l>, <lambda1>, <lambda2>)
##
##  <#GAPDoc Label="SomeRefinedDifferenceSumsOfDivisibleDifferenceSet">
##  <ManSection>
##  <Func Name="SomeRefinedDifferenceSumsOfDivisibleDifferenceSet" Arg="G, N1, N2, difsums, w, v, l, lambda1, lambda2"/>
##
##  <Description>
##  Returns a list of some difference sums in group <A>G</A> mod its normal
##  subgroup <A>N2</A> that are preimages of difference sums contained in
##  the list <A>difsums</A> of difference sums in group <A>G</A> mod its
##  normal subgroup <A>N1</A>. At least one member of each equivalence class
##  that would appear in the set of all preimages will be returned, but all
##  preimage difference sums may not appear. The subgroup <A>N2</A> must be
##  contained in <A>N1</A> and difference sums in <A>difsums</A> are all
##  assumed to be the same size. Current implementation forces a choice
##  of nonzero identity coefficient when possible.
##
##  <Example><![CDATA[
##  gap> G := SmallGroup(16, 5);;
##  gap> N1 := Subgroup(G, [G.2, G.4]);;
##  gap> N2 := Subgroup(G, [G.2]);;
##  gap> SomeRefinedDifferenceSumsOfDivisibleDifferenceSet(G, N1, N2,[[3,1,1,1], [2,2,2,0]],16,1,6,0,2);
##  [  ]
##  ]]></Example>
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
# FEATURE SomeRefinedDifferenceSumsOfDivisibleDifferenceSet(G, N1, N2, difsums, w, v, l, lambda1, lambda2)
DeclareGlobalFunction( "SomeRefinedDifferenceSumsOfDivisibleDifferenceSet" );

#############################################################################
##
#F  SomeRefinedDifferenceSumsOfDivisibleDifferenceSetPair( <G>, <N1>, <N2>, <difsums>, <w>, <v>, <l1>, <l2>, <le>, <lambda1>, <lambda2>)
##
##  <#GAPDoc Label="SomeRefinedDifferenceSumsOfDivisibleDifferenceSetPair">
##  <ManSection>
##  <Func Name="SomeRefinedDifferenceSumsOfDivisibleDifferenceSetPair" Arg="G, N1, N2, difsums, w, v, l1, l2, le, lambda1, lambda2"/>
##
##  <Description>
##  Returns a list of some difference sums in group <A>G</A> mod its normal
##  subgroup <A>N2</A> that are preimages of difference sums contained in
##  the list <A>difsums</A> of difference sums in group <A>G</A> mod its
##  normal subgroup <A>N1</A>. At least one member of each equivalence class
##  that would appear in the set of all preimages will be returned, but all
##  preimage difference sums may not appear. The subgroup <A>N2</A> must be
##  contained in <A>N1</A> and difference sums in <A>difsums</A> are all
##  assumed to be the same size. Current implementation forces a choice
##  of nonzero identity coefficient when possible.
##
##  <Example><![CDATA[
##  gap> G := SmallGroup(16, 5);;
##  gap> N1 := Subgroup(G, [G.2, G.4]);;
##  gap> N2 := Subgroup(G, [G.2]);;
##  gap> SomeRefinedDifferenceSumsOfDivisibleDifferenceSetPair(G, N1, N2, [[[3,1,1,1],[3,1,1,1]], [[2,2,2,0],[2,2,2,0]]],16,1,6,6,6,0,2);
##  [  ]
##  ]]></Example>
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
# FEATURE SomeRefinedDifferenceSumsOfDivisibleDifferenceSetPair(G, N1, N2, difsums, w, v, l1, l2, le, lambda1, lambda2)
DeclareGlobalFunction( "SomeRefinedDifferenceSumsOfDivisibleDifferenceSetPair" );

#############################################################################
##
#F  DifferenceSumPreImagesOptions( <u>, <w>, <S> )
##
##  <#GAPDoc Label="DifferenceSumPreImagesOptions">
##  <ManSection>
##  <Func Name="DifferenceSumPreImagesOptions" Arg="u, w, S"/>
##  </ManSection>
##  <#/GAPDoc>
DeclareGlobalFunction( "DifferenceSumPreImagesOptions" );

#############################################################################
##
#F  DifferenceSumPreImagesPermutations( <opt> )
##
##  <#GAPDoc Label="DifferenceSumPreImagesPermutations">
##  <ManSection>
##  <Func Name="DifferenceSumPreImagesPermutations" Arg="opt"/>
##  </ManSection>
##  <#/GAPDoc>
DeclareGlobalFunction( "DifferenceSumPreImagesPermutations" );

#############################################################################
##
#F  DifferenceSumPreImagesPermutationsForced( <opt> )
##
##  <#GAPDoc Label="DifferenceSumPreImagesPermutationsForced">
##  <ManSection>
##  <Func Name="DifferenceSumPreImagesPermutationsForced" Arg="opt"/>
##  </ManSection>
##  <#/GAPDoc>
DeclareGlobalFunction( "DifferenceSumPreImagesPermutationsForced" );

#############################################################################
##
#F  DifferenceSumPreImagesTranslate( <cosets>, <u1>, <u2>, <u3>, <perm> )
##
##  <#GAPDoc Label="DifferenceSumPreImagesTranslate">
##  <ManSection>
##  <Func Name="DifferenceSumPreImagesTranslate" Arg="cosets, u1, u2, u3, perm"/>
##  </ManSection>
##  <#/GAPDoc>
DeclareGlobalFunction( "DifferenceSumPreImagesTranslate" );

#############################################################################
##
#F  IsDifferenceSumByTable( <table>, <S>, <v>, <k>, <lambda>, <w> )
##
##  <#GAPDoc Label="IsDifferenceSumByTable">
##  <ManSection>
##  <Func Name="IsDifferenceSumByTable" Arg="table, S, v, k, lambda, w"/>
##  </ManSection>
##  <#/GAPDoc>
DeclareGlobalFunction( "IsDifferenceSumByTable" );

#############################################################################
##
#F  IsDifferenceSumByTableOfDifferenceSetPair( <table>, <S1>, <S2>, <u>, <nonid>)
##
##  <#GAPDoc Label="IsDifferenceSumByTableOfDifferenceSetPair">
##  <ManSection>
##  <Func Name="IsDifferenceSumByTableOfDifferenceSetPair" Arg="table, S1, S2, u, nonid"/>
##  </ManSection>
##  <#/GAPDoc>
# FEATURE IsDifferenceSumByTableOfDifferenceSetPair(table, S1, S2, u, nonid)
DeclareGlobalFunction( "IsDifferenceSumByTableOfDifferenceSetPair" );

#############################################################################
##
#F  IsDifferenceSumByTableOfDivisibleDifferenceSet( <table>, <S>, <u>, <nonid>)
##
##  <#GAPDoc Label="IsDifferenceSumByTableOfDivisibleDifferenceSet">
##  <ManSection>
##  <Func Name="IsDifferenceSumByTableOfDivisibleDifferenceSet" Arg="table, S, u, nonid"/>
##  </ManSection>
##  <#/GAPDoc>
# FEATURE IsDifferenceSumByTableOfDivisibleDifferenceSet(table, S, u, nonid)
DeclareGlobalFunction( "IsDifferenceSumByTableOfDivisibleDifferenceSet" );

#############################################################################
##
#F  IsDifferenceSumByTableOfDivisibleDifferenceSetPair(<table>, <S1>, <S2>, <u>, <nonid>)
##
##  <#GAPDoc Label="IsDifferenceSumByTableOfDivisibleDifferenceSetPair">
##  <ManSection>
##  <Func Name="IsDifferenceSumByTableOfDivisibleDifferenceSetPair" Arg="table, S1, S2, u, nonid"/>
##  </ManSection>
##  <#/GAPDoc>
# FEATURE IsDifferenceSumByTableOfDivisibleDifferenceSetPair(table, S1, S2, u, nonid)
DeclareGlobalFunction( "IsDifferenceSumByTableOfDivisibleDifferenceSetPair" );

#############################################################################
##
#E

